﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.UserInfoCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.UserInfoHandlers
{
   /// <summary>
   /// 用户逻辑删除
   /// </summary>
    public class UserInfoDeleteHandler : IRequestHandler<UserInfoDeleteCommand, Results<int>>
    {
        private readonly IUserInfoService userInfoService;
        private readonly IMapper mapper;


        public UserInfoDeleteHandler(IUserInfoService userInfoService, IMapper mapper)
        {
            this.userInfoService = userInfoService;
            this.mapper = mapper;
        }

        /// <summary>
        /// 用户逻辑删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<int>> Handle(UserInfoDeleteCommand request, CancellationToken cancellationToken)
        {
          // throw new NotImplementedException();

            var res= await userInfoService.UserInfoDelete(request.UserId);


            return Results<int>.DataResult(res);

        }
    }
}
